'''
Created on Oct 15, 2009

@author: Owner
'''
import time

import __builtin__
import gamephase.menu
import gamephase.humanVsHuman
import gamephase.computerVsComputer
import gamephase.delay

class GlobalVariables(object):
	'''
	classdocs
	'''
	__game_phase = None
	
	def __init__(self, params):
		'''
		Constructor
		'''
	
	def getGame_phase(self):
		return self.__game_phase
	
	def setGame_phase(self, value):
		if not isinstance(value, GP.GamePhase):
			return
		self.__game_phase = value
	
	def delGame_phase(self):
		del self.__game_phase
	
	game_phase = property(getGame_phase, setGame_phase, delGame_phase, "Game_phase's Docstring")

G = GlobalVariables
__builtin__.G = G

class GlobalController(object):
	'''
	classdocs
	'''
	
	def __init__(self, params):
		'''
		Constructor
		'''
	@staticmethod
	def init():
		print("Game is initializing")
	
		G.game_phase = gamephase.menu.MainMenu()
	#        G.game_phase = GP.GamePhaseWonder()
#		G.game_phase = gamephase.humanVsHuman.HumanVsHuman()
#		G.game_phase = gamephase.computerVsComputer.ComputerVsComputer()
		return True
	
	@staticmethod
	def main():
		print("Game begins")
		
		while(GlobalVariables.game_phase != None):
			GlobalVariables.game_phase.execute()
			time.sleep(0.1)
		return True
	
	@staticmethod
	def finalize():
		print("That's the end")
		pass

	@staticmethod
	def delay(count, on_finish_phase = None):
		if on_finish_phase == None:
			on_finish_phase = __builtin__.G.game_phase
		G.game_phase = gamephase.delay.Delay(count, on_finish_phase)
		return
	
def test():
	return 1 + 1

GC = GlobalController
import gamephase.game_phase as GP